Imports System.Xml
Imports System.Data.SqlClient
Public Class dNotaDeDebito
    Public Function Existe(ByVal idNotaDeDebito As String) As Boolean
        Dim Parametros As ArrayList = New ArrayList
        If idNotaDeDebito <> "" Then
            Parametros.Add(New SqlParameter("@pEidNotaDeDebito", idNotaDeDebito))
        End If
        Return (dConexion.Consultar("STORE_TblNotaDeDebitoBUSCARFILTRADO", Parametros).Tables(0).Rows(0).ItemArray(0) = 1)
    End Function
    Public Function Insertar(ByVal Numero As String, ByVal IdTalonario As String, ByVal IdFactura As String, ByVal Total As String, ByVal Concepto As String) As Boolean
        Dim Parametros As ArrayList = New ArrayList
        If Numero <> "" Then
            Parametros.Add(New SqlParameter("@pENumero", Numero))
        End If
        If IdTalonario <> "" Then
            Parametros.Add(New SqlParameter("@pEIdTalonario", IdTalonario))
        End If
        If IdFactura <> "" Then
            Parametros.Add(New SqlParameter("@pEIdFactura", IdFactura))
        End If
        If Total <> "" Then
            Parametros.Add(New SqlParameter("@pETotal", CDbl(Total)))
        End If
        If Concepto <> "" Then
            Parametros.Add(New SqlParameter("@pEConcepto", Concepto))
        End If
        Return dConexion.ABM("STORE_TblNotaDeDebitoALTA", Parametros)
    End Function
    Public Function Eliminar(ByVal idNotaDeDebito As String) As Boolean
        Dim Parametros As ArrayList = New ArrayList
        If idNotaDeDebito <> "" Then
            Parametros.Add(New SqlParameter("@pEidNotaDeDebito", idNotaDeDebito))
        End If
        Return dConexion.ABM("STORE_TblNotaDeDebitoELIMINAR", Parametros)
    End Function
    Public Function BuscarFiltrado(ByVal idNotaDeDebito As String, ByVal Numero As String, ByVal Fecha As String, ByVal IdTalonario As String, ByVal IdFactura As String, ByVal Total As String, ByVal Concepto As String) As DataSet
        Dim Parametros As ArrayList = New ArrayList
        If idNotaDeDebito <> "" Then
            Parametros.Add(New SqlParameter("@pEidNotaDeDebito", idNotaDeDebito))
        End If
        If Numero <> "" Then
            Parametros.Add(New SqlParameter("@pENumero", Numero))
        End If
        If Fecha <> "" Then
            Parametros.Add(New SqlParameter("@pEFecha", Fecha))
        End If
        If IdTalonario <> "" Then
            Parametros.Add(New SqlParameter("@pEIdTalonario", IdTalonario))
        End If
        If IdFactura <> "" Then
            Parametros.Add(New SqlParameter("@pEIdFactura", IdFactura))
        End If
        If Total <> "" Then
            Parametros.Add(New SqlParameter("@pETotal", CDbl(Total)))
        End If
        If Concepto <> "" Then
            Parametros.Add(New SqlParameter("@pEConcepto", Concepto))
        End If
        Return dConexion.Consultar("STORE_TblNotaDeDebitoBUSCARFILTRADO", Parametros)
    End Function
    Public Function ObtenerNumero(ByVal CodigoCategoria As String) As DataSet
        Dim Parametros As ArrayList = New ArrayList
        Parametros.Add(New SqlParameter("@pECodigoCategoria", CodigoCategoria))
        Return dConexion.Consultar("STORE_TblNotaDeDebitoBuscarUltimoNumero", Parametros)
    End Function
End Class
